package com.frejoys.app.controller;

import com.frejoys.common.aop.Authority;
import com.frejoys.common.aop.Authorization;
import com.frejoys.common.constant.CommonConstant;
import com.frejoys.common.dto.app.AgentStoreIdDto;
import com.frejoys.common.dto.common.PageDto;
import com.frejoys.common.response.Result;
import com.frejoys.common.util.RequestUtil;
import com.frejoys.common.vo.agent.AgentStoreVo;
import com.frejoys.common.vo.app.AgentStoreInfoVo;
import com.frejoys.common.vo.app.AgentStoreListVo;
import com.frejoys.service.AgentStoreService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "代理服务商家", description = "代理服务商家")
@RestController
@RequiredArgsConstructor
@RequestMapping(CommonConstant.routePrefixApp)
 @Authorization(Authority.Private)
public class AgentStoreController {

    private final AgentStoreService agentStoreService;

    /**
     * 根据代理人id获取代理店铺列表
     */
    @Operation(summary = "代理人获取我的商家列表")
    @PostMapping("/agent/store/listAgentStore")
    public Result<List<AgentStoreListVo>> listAgentStore(@RequestBody @Validated PageDto dto) {
        return Result.success(agentStoreService.listAgentStoreByUserId(dto,RequestUtil.userId()));
    }

    @Operation(summary = "代理人获取我的商家详情")
    @PostMapping("/agent/store/agentStoreInfo")
    public Result<AgentStoreInfoVo> agentStoreInfo(@RequestBody @Validated AgentStoreIdDto dto) {
        return Result.success(agentStoreService.agentStoreInfo(dto.getId()));
    }

}
